#include <stdio.h>
#include <pthread.h>
#include <error.h>
#include <errno.h>
#include <stdlib.h>

typedef struct{
    int a;
    int b;
    int c;
}Foo;

void* start_routine(void* args)
{
    Foo* x = (Foo*)malloc(sizeof(Foo));
    x->a = 1;
    x->b = 2;
    x->c = 3;
    
    return x;
}

int main()
{
    //创建线程
    pthread_t tid;
    int err = pthread_create(&tid, NULL, start_routine, NULL);
    if(err)
    {
        error(1, err, "pthread_create");
    }
    Foo* x;
    pthread_join(tid, (void**)&x); //阻塞，等待tid线程结束
    printf("mian pthread : retval = {%d, %d, %d}\n", x->a, x->b, x->c);

    free(x);
    return 0;
}